home *** CD-ROM | disk | FTP | other *** search
- ////////////////////////////////////////////////////////////////////////////////
- //
- // uBrowser - a program that illustrates one way of embedding the
- // Mozilla Gecko (tm) Rendering Engine in an application, grabbing the
- // rendered output and displaying it on the surface of a 3D polygon as
- // texture in an OpenGL (tm) application.
- //
- // uBrowser is free software; you can redistribute it and/or modify
- // it under the terms of the GNU General Public License as published by
- // the Free Software Foundation; either version 2 of the License, or
- // (at your option) any later version.
- //
- // uBrowser is distributed in the hope that it will be useful,
- // but WITHOUT ANY WARRANTY; without even the implied warranty of
- // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- // GNU General Public License for more details.
- //
- // You should have received a copy of the GNU General Public License
- // along with uBrowser; if not, write to the Free Software
- // Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
- //
- // Original code: Copyright 2005 Linden Research Inc.
- // http://www.lindenlab.com
- //
- // Primary author and site maintainer: Callum Prentice (callum@ubrowser.com)
- //
- // See contributors.txt or http://ubrowser.com for a list of contributors
- // without whose generous donation of time and effort, this application
- // would not have been possible.
- //
- ////////////////////////////////////////////////////////////////////////////////
- #include "ubrowser.h"
-
- #include "GL/glut.h"
- #include "glui.h"
-
- uBrowser* theUBrowser;
-
- ////////////////////////////////////////////////////////////////////////////////
- //
- void glutReshape( int widthIn, int heightIn )
- {
- if ( theUBrowser )
- theUBrowser->reshape( widthIn, heightIn );
- };
-
- ////////////////////////////////////////////////////////////////////////////////
- //
- void glutDisplay()
- {
- if ( theUBrowser )
- theUBrowser->display();
- };
-
- ////////////////////////////////////////////////////////////////////////////////
- //
- void glutIdle()
- {
- if ( theUBrowser )
- theUBrowser->idle();
- };
-
- ////////////////////////////////////////////////////////////////////////////////
- //
- void glutKeyboard( unsigned char keyIn, int xIn, int yIn )
- {
- if ( theUBrowser )
- theUBrowser->keyboard( keyIn, xIn, yIn );
- };
-
- ////////////////////////////////////////////////////////////////////////////////
- //
- void glutSpecialKeyboard( int keyIn, int xIn, int yIn )
- {
- // appears that you need this defined even if it's empty
- // passing NULL for the handler func ptr crashes this app
- };
-
- ////////////////////////////////////////////////////////////////////////////////
- //
- void glutPassiveMouse( int xIn, int yIn )
- {
- if ( theUBrowser )
- theUBrowser->passiveMouse( xIn, yIn );
- }
-
- ////////////////////////////////////////////////////////////////////////////////
- //
- void glutMouseMove( int xIn , int yIn )
- {
- if ( theUBrowser )
- theUBrowser->mouseMove( xIn, yIn );
- }
-
- ////////////////////////////////////////////////////////////////////////////////
- //
- void glutMouseButton( int buttonIn, int stateIn, int xIn, int yIn )
- {
- if ( theUBrowser )
- theUBrowser->mouseButton( buttonIn, stateIn, xIn, yIn );
- }
-
- ////////////////////////////////////////////////////////////////////////////////
- //
- int main( int argc, char* argv[] )
- {
- theUBrowser = new uBrowser;
-
- if ( theUBrowser )
- {
- glutInit( &argc, argv );
- glutInitDisplayMode( GLUT_DEPTH | GLUT_DOUBLE | GLUT_RGB );
-
- glutInitWindowPosition( 80, 0 );
- glutInitWindowSize( 1024, 900 );
-
- int appWindow = glutCreateWindow( theUBrowser->getName().c_str() );
-
- glutDisplayFunc( glutDisplay );
-
- GLUI_Master.set_glutReshapeFunc( glutReshape );
- GLUI_Master.set_glutKeyboardFunc( glutKeyboard );
- GLUI_Master.set_glutMouseFunc( glutMouseButton );
- GLUI_Master.set_glutSpecialFunc( glutSpecialKeyboard );
-
- glutPassiveMotionFunc( glutPassiveMouse );
- glutMotionFunc( glutMouseMove );
-
- glutSetWindow( appWindow );
-
- theUBrowser->init( argv[ 0 ], appWindow );
-
- GLUI_Master.set_glutIdleFunc( glutIdle );
-
- glutMainLoop();
-
- if ( theUBrowser )
- delete theUBrowser;
- };
-
- return 1;
- }